# gen_fig3 makefile

TASK_DIR:=$(dir $(abspath $(lastword $(MAKEFILE_LIST))))

include ../../config.mk

# Scripts
SRC := $(TASK_DIR)/src/gen_pathway_risk_plots.R

# Inputs (that have not already been specified in config.mk)
CONFIG_FILE := $(TASK_DIR)/hand/config.yaml
TWO_SUBGROUPS_RESULTS_FILE := $(TASK_DIR)/../../run_regressions/output/regression_output__two_subgroups_parsimonious_spec.csv

# Outputs
OUT_MAIN_FIGURE := $(OUT_DIR)/main_pathway_baseline_risk_up_to_date.pdf
OUT_APPENDIX_FIGURE := $(OUT_DIR)/appendix_pathway_baseline_risk_up_to_date.pdf

# Recipes

$(OUT_APPENDIX_FIGURE): $(SRC) $(CONFIG_FILE) $(PROJECT_CONFIG) $(TASK_FNS) $(XSECTION_ANALYSIS_FILE) $(PAYROLL_FILE) $(TWO_SUBGROUPS_RESULTS_FILE)
	@mkdir -p $(OUT_DIR)
	@mkdir -p $(PAPER_OUT_DIR)
	@$(R_script) $< \
		--CONFIG_FILE=$(CONFIG_FILE) \
		--PROJECT_CONFIG=$(PROJECT_CONFIG) \
		--XSECTION_ANALYSIS_FILE=$(XSECTION_ANALYSIS_FILE) \
		--PAYROLL_FILE=$(PAYROLL_FILE) \
		--TWO_SUBGROUPS_RESULTS_FILE=$(TWO_SUBGROUPS_RESULTS_FILE) \
		--OUT_MAIN_FIGURE=$(OUT_MAIN_FIGURE) \
		--OUT_APPENDIX_FIGURE=$(OUT_APPENDIX_FIGURE)
	@cp $(OUT_DIR)/*up_to_date.pdf $(PAPER_OUT_DIR)

.PHONY: all clean
.DEFAULT_GOAL=all

all: $(OUT_APPENDIX_FIGURE)

clean:
	rm -rf $(OUT_DIR)/*
